<?php

/**
 * @author 	Samuel Carlier
 * @package 	P3Base_Mailer
 */
class P3Base_Mailer_Headers {

	/**
	 * @var array
	 */
	private $_headers;
	
	/**
	 * @param string $name
	 * @param string $value
	 * @param bool 	 $overwrite
	 */
	public function add($name, $value, $overwrite=true) {
		if($overwrite === false) {
			if(key_exists($name, $this->_headers)) {
				return;	
			}	
		}

		$this->_headers[$name] = $value;
	}
	
	/**
	 * @return array
	 */
	public function get() {
		return $this->_headers;
	}
	
	/**
	 * @param string $iteratorName 	mail
	 *
	 * @return Iterator
	 */
	public function getIterator($iteratorName='mail') {
		$iteratorName = strtolower($iteratorName);

		switch($iteratorName) {
			case 'mail':
				$iterator = new P3Base_Mailer_Iterator_MailHeader($this->get());
			break;	

			default:
				throw new P3Base_Mailer_Exception('unsupported iterator: "'.$iteratorName.'"');
		}

		return $iterator;
	}
}

?>